<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/WEB-INF/mob/template.xhtml"
                xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">
    <ui:define name="content">
        <style>
            .panel-header {
                background-color: #007bff;
                color: white;
                padding: 15px;
                border-bottom: 1px solid #0069d9;
                font-weight: bold;
                font-size: 24px !important;
                text-align: center;
                border-radius: 5px 5px 0 0;
                margin-bottom: 20px; /* 增加底部间距 */
            }
            .panel-content {
                padding: 20px;
                background-color: #f8f9fa;
                border-radius: 0 0 5px 5px;
                margin-top: 20px; /* 增加上方间距 */
            }
            .menu-button {
                margin-left: 10px;
            }
            .data-table-header {
                background-color: #f8f9fa;
                font-weight: bold;
                text-align: center !important;
                border-bottom: 1px solid #dee2e6;
            }
            .data-table-cell {
                padding: 10px;
                text-align: center;
                border-bottom: 1px solid #dee2e6;
            }
            .ui-growl {
                z-index: 11000;
            }
            .ui-growl-item-container {
                display: flex;
                align-items: center;
                justify-content: center;
                text-align: center;
            }
            .ui-growl-message {
                text-align: center;
            }
            .report-dialog-content {
                white-space: pre-wrap;
                word-wrap: break-word;
                max-height: 400px;
                overflow-y: auto;
                padding: 20px;
                border-radius: 5px;
                background-color: #ffffff;
            }
            .report-dialog-textarea {
                width: 100%;
                height: 400px;
                border: none;
                background-color: transparent;
                resize: none;
                font-family: monospace;
                font-size: 14px;
            }
            .button-group {
                display: flex;
                justify-content: flex-end;
                margin-top: 20px; /* 增加上方间距 */
                margin-bottom: 20px; /* 增加底部间距 */
            }
        </style>
        <h:form id="logList">
            <p:panel id="fydslist" styleClass="panel-header">
                <span>项目日志</span>
            </p:panel>
            <p:growl id="msg" life="26500" styleClass="ui-growl" />
            <div class="button-group">
                <p:commandButton value="查询" icon="pi pi-search" process="@this"
                                 update="msg, @form:logs"
                                 actionListener="#{mkzbd.bb('log').mc.select()}"
                                 styleClass="ui-button-primary menu-button" />
            </div>
            <p:panel id="fydDemoLists" styleClass="panel-content" style="height: calc(100% - 160px); position: relative; overflow: hidden; margin-top: 20px;">
                <!-- 数据表 -->
                <p:dataTable emptyMessage="无记录" id="logs" var="li" rowIndexVar="lia" showGridlines="true"
                             stripedRows="true" resizableColumns="true" selectionMode="single" selection="#{mkzbd.bb('log').mc.lbselectrow}"
                             value="#{mkzbd.bb('log').mc.datalist}" reflow="true" styleClass="p-datatable-sm p-datatable-striped"
                             scrollable="true" scrollHeight="calc(100% - 40px)"
                             rowKey="#{li.id}" paginator="true" rows="10" style="visibility: visible !important"
                             paginatorPosition="bottom" rowsPerPageTemplate="10,20,50,100"
                             sortBy="#{li.time}" sortOrder="descending">
                    <p:column headerText="请求响应码" styleClass="data-table-header" style="width: 70px;" sortBy="#{li.code}">
                        <h:outputText value="#{li.code}" styleClass="data-table-cell" />
                    </p:column>
                    <p:column headerText="信息" styleClass="data-table-header" style="width: 100px;" sortBy="#{li.message}">
                        <h:outputText value="#{li.message}" styleClass="data-table-cell" />
                    </p:column>
                    <p:column headerText="是否成功" styleClass="data-table-header" style="width: 70px;" sortBy="#{li.success}">
                        <h:outputText value="#{li.success}" styleClass="data-table-cell" />
                    </p:column>
                    <p:column headerText="状态" styleClass="data-table-header" style="width: 70px;" sortBy="#{li.state}">
                        <h:outputText value="#{li.state}" styleClass="data-table-cell" />
                    </p:column>
                    <p:column headerText="Ascript" styleClass="data-table-header" style="width: 70px;" sortBy="#{li.Ascript}">
                        <h:outputText value="#{li.Ascript}" styleClass="data-table-cell" />
                    </p:column>
                    <p:column headerText="时间" styleClass="data-table-header" style="width: 150px;" sortBy="#{li.time}">
                        <h:outputText value="#{li.time}" styleClass="data-table-cell" />
                    </p:column>
                    <p:column style="width: 100px;">
                        <p:commandButton value="查询WMS报文" icon="pi pi-search"
                                         actionListener="#{mkzbd.bb('log').mc.queryWMSReport(li.id)}"
                                         oncomplete="if (args &amp;&amp; !args.validationFailed) {PF('reportDialog').show();}"
                                         update=":logList:msg, :logList:reportDialogContent"
                                         styleClass="p-button-raised p-button-secondary" />
                    </p:column>
                    <p:column style="width: 100px;">
                        <p:commandButton value="查询传入数据" icon="pi pi-search"
                                         actionListener="#{mkzbd.bb('log').mc.queryRequestData(li.id)}"
                                         oncomplete="if (args &amp;&amp; !args.validationFailed) {PF('requestDataDialog').show();}"
                                         update=":logList:msg, :logList:requestDataDialogContent"
                                         styleClass="p-button-raised p-button-secondary" />
                    </p:column>
                </p:dataTable>
            </p:panel>

            <!-- WMS 报文弹窗 -->
            <p:dialog widgetVar="reportDialog" header="WMS 报文" modal="true" width="800" height="500" resizable="false" styleClass="p-dialog-lg">
                <p:outputPanel id="reportDialogContent" styleClass="report-dialog-content">
                    <p:inputTextarea id="wmsReportTextArea" value="#{mkzbd.bb('log').mc.wmsReport}"
                                     styleClass="report-dialog-textarea"
                                     readonly="true" />
                </p:outputPanel>
            </p:dialog>

            <!-- 传入数据弹窗 -->
            <p:dialog widgetVar="requestDataDialog" header="传入数据" modal="true" width="800" height="500" resizable="false" styleClass="p-dialog-lg">
                <p:outputPanel id="requestDataDialogContent" styleClass="report-dialog-content">
                    <p:inputTextarea id="requestDataTextArea" value="#{mkzbd.bb('log').mc.requestData}"
                                     styleClass="report-dialog-textarea"
                                     readonly="true" />
                </p:outputPanel>
            </p:dialog>
        </h:form>
    </ui:define>
</ui:composition>